{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pickle as pkl\n",
    "import pandas as pd\n",
    "import random\n",
    "import numpy as np\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>article_id</th>\n",
       "      <th>product_code</th>\n",
       "      <th>prod_name</th>\n",
       "      <th>product_type_no</th>\n",
       "      <th>product_type_name</th>\n",
       "      <th>product_group_name</th>\n",
       "      <th>graphical_appearance_no</th>\n",
       "      <th>graphical_appearance_name</th>\n",
       "      <th>colour_group_code</th>\n",
       "      <th>colour_group_name</th>\n",
       "      <th>...</th>\n",
       "      <th>department_name</th>\n",
       "      <th>index_code</th>\n",
       "      <th>index_name</th>\n",
       "      <th>index_group_no</th>\n",
       "      <th>index_group_name</th>\n",
       "      <th>section_no</th>\n",
       "      <th>section_name</th>\n",
       "      <th>garment_group_no</th>\n",
       "      <th>garment_group_name</th>\n",
       "      <th>detail_desc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0108775015</td>\n",
       "      <td>0108775</td>\n",
       "      <td>Strap top</td>\n",
       "      <td>253</td>\n",
       "      <td>Vest top</td>\n",
       "      <td>Garment Upper body</td>\n",
       "      <td>1010016</td>\n",
       "      <td>Solid</td>\n",
       "      <td>09</td>\n",
       "      <td>Black</td>\n",
       "      <td>...</td>\n",
       "      <td>Jersey Basic</td>\n",
       "      <td>A</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>1</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>16</td>\n",
       "      <td>Womens Everyday Basics</td>\n",
       "      <td>1002</td>\n",
       "      <td>Jersey Basic</td>\n",
       "      <td>Jersey top with narrow shoulder straps.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0108775044</td>\n",
       "      <td>0108775</td>\n",
       "      <td>Strap top</td>\n",
       "      <td>253</td>\n",
       "      <td>Vest top</td>\n",
       "      <td>Garment Upper body</td>\n",
       "      <td>1010016</td>\n",
       "      <td>Solid</td>\n",
       "      <td>10</td>\n",
       "      <td>White</td>\n",
       "      <td>...</td>\n",
       "      <td>Jersey Basic</td>\n",
       "      <td>A</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>1</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>16</td>\n",
       "      <td>Womens Everyday Basics</td>\n",
       "      <td>1002</td>\n",
       "      <td>Jersey Basic</td>\n",
       "      <td>Jersey top with narrow shoulder straps.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0108775051</td>\n",
       "      <td>0108775</td>\n",
       "      <td>Strap top (1)</td>\n",
       "      <td>253</td>\n",
       "      <td>Vest top</td>\n",
       "      <td>Garment Upper body</td>\n",
       "      <td>1010017</td>\n",
       "      <td>Stripe</td>\n",
       "      <td>11</td>\n",
       "      <td>Off White</td>\n",
       "      <td>...</td>\n",
       "      <td>Jersey Basic</td>\n",
       "      <td>A</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>1</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>16</td>\n",
       "      <td>Womens Everyday Basics</td>\n",
       "      <td>1002</td>\n",
       "      <td>Jersey Basic</td>\n",
       "      <td>Jersey top with narrow shoulder straps.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0110065001</td>\n",
       "      <td>0110065</td>\n",
       "      <td>OP T-shirt (Idro)</td>\n",
       "      <td>306</td>\n",
       "      <td>Bra</td>\n",
       "      <td>Underwear</td>\n",
       "      <td>1010016</td>\n",
       "      <td>Solid</td>\n",
       "      <td>09</td>\n",
       "      <td>Black</td>\n",
       "      <td>...</td>\n",
       "      <td>Clean Lingerie</td>\n",
       "      <td>B</td>\n",
       "      <td>Lingeries/Tights</td>\n",
       "      <td>1</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>61</td>\n",
       "      <td>Womens Lingerie</td>\n",
       "      <td>1017</td>\n",
       "      <td>Under-, Nightwear</td>\n",
       "      <td>Microfibre T-shirt bra with underwired, moulde...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0110065002</td>\n",
       "      <td>0110065</td>\n",
       "      <td>OP T-shirt (Idro)</td>\n",
       "      <td>306</td>\n",
       "      <td>Bra</td>\n",
       "      <td>Underwear</td>\n",
       "      <td>1010016</td>\n",
       "      <td>Solid</td>\n",
       "      <td>10</td>\n",
       "      <td>White</td>\n",
       "      <td>...</td>\n",
       "      <td>Clean Lingerie</td>\n",
       "      <td>B</td>\n",
       "      <td>Lingeries/Tights</td>\n",
       "      <td>1</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>61</td>\n",
       "      <td>Womens Lingerie</td>\n",
       "      <td>1017</td>\n",
       "      <td>Under-, Nightwear</td>\n",
       "      <td>Microfibre T-shirt bra with underwired, moulde...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>105537</th>\n",
       "      <td>0953450001</td>\n",
       "      <td>0953450</td>\n",
       "      <td>5pk regular Placement1</td>\n",
       "      <td>302</td>\n",
       "      <td>Socks</td>\n",
       "      <td>Socks &amp; Tights</td>\n",
       "      <td>1010014</td>\n",
       "      <td>Placement print</td>\n",
       "      <td>09</td>\n",
       "      <td>Black</td>\n",
       "      <td>...</td>\n",
       "      <td>Socks Bin</td>\n",
       "      <td>F</td>\n",
       "      <td>Menswear</td>\n",
       "      <td>3</td>\n",
       "      <td>Menswear</td>\n",
       "      <td>26</td>\n",
       "      <td>Men Underwear</td>\n",
       "      <td>1021</td>\n",
       "      <td>Socks and Tights</td>\n",
       "      <td>Socks in a fine-knit cotton blend with a small...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>105538</th>\n",
       "      <td>0953763001</td>\n",
       "      <td>0953763</td>\n",
       "      <td>SPORT Malaga tank</td>\n",
       "      <td>253</td>\n",
       "      <td>Vest top</td>\n",
       "      <td>Garment Upper body</td>\n",
       "      <td>1010016</td>\n",
       "      <td>Solid</td>\n",
       "      <td>09</td>\n",
       "      <td>Black</td>\n",
       "      <td>...</td>\n",
       "      <td>Jersey</td>\n",
       "      <td>A</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>1</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>2</td>\n",
       "      <td>H&amp;M+</td>\n",
       "      <td>1005</td>\n",
       "      <td>Jersey Fancy</td>\n",
       "      <td>Loose-fitting sports vest top in ribbed fast-d...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>105539</th>\n",
       "      <td>0956217002</td>\n",
       "      <td>0956217</td>\n",
       "      <td>Cartwheel dress</td>\n",
       "      <td>265</td>\n",
       "      <td>Dress</td>\n",
       "      <td>Garment Full body</td>\n",
       "      <td>1010016</td>\n",
       "      <td>Solid</td>\n",
       "      <td>09</td>\n",
       "      <td>Black</td>\n",
       "      <td>...</td>\n",
       "      <td>Jersey</td>\n",
       "      <td>A</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>1</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>18</td>\n",
       "      <td>Womens Trend</td>\n",
       "      <td>1005</td>\n",
       "      <td>Jersey Fancy</td>\n",
       "      <td>Short, A-line dress in jersey with a round nec...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>105540</th>\n",
       "      <td>0957375001</td>\n",
       "      <td>0957375</td>\n",
       "      <td>CLAIRE HAIR CLAW</td>\n",
       "      <td>72</td>\n",
       "      <td>Hair clip</td>\n",
       "      <td>Accessories</td>\n",
       "      <td>1010016</td>\n",
       "      <td>Solid</td>\n",
       "      <td>09</td>\n",
       "      <td>Black</td>\n",
       "      <td>...</td>\n",
       "      <td>Small Accessories</td>\n",
       "      <td>D</td>\n",
       "      <td>Divided</td>\n",
       "      <td>2</td>\n",
       "      <td>Divided</td>\n",
       "      <td>52</td>\n",
       "      <td>Divided Accessories</td>\n",
       "      <td>1019</td>\n",
       "      <td>Accessories</td>\n",
       "      <td>Large plastic hair claw.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>105541</th>\n",
       "      <td>0959461001</td>\n",
       "      <td>0959461</td>\n",
       "      <td>Lounge dress</td>\n",
       "      <td>265</td>\n",
       "      <td>Dress</td>\n",
       "      <td>Garment Full body</td>\n",
       "      <td>1010016</td>\n",
       "      <td>Solid</td>\n",
       "      <td>11</td>\n",
       "      <td>Off White</td>\n",
       "      <td>...</td>\n",
       "      <td>Jersey</td>\n",
       "      <td>A</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>1</td>\n",
       "      <td>Ladieswear</td>\n",
       "      <td>18</td>\n",
       "      <td>Womens Trend</td>\n",
       "      <td>1005</td>\n",
       "      <td>Jersey Fancy</td>\n",
       "      <td>Calf-length dress in ribbed jersey made from a...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>105542 rows × 25 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        article_id product_code               prod_name product_type_no  \\\n",
       "0       0108775015      0108775               Strap top             253   \n",
       "1       0108775044      0108775               Strap top             253   \n",
       "2       0108775051      0108775           Strap top (1)             253   \n",
       "3       0110065001      0110065       OP T-shirt (Idro)             306   \n",
       "4       0110065002      0110065       OP T-shirt (Idro)             306   \n",
       "...            ...          ...                     ...             ...   \n",
       "105537  0953450001      0953450  5pk regular Placement1             302   \n",
       "105538  0953763001      0953763       SPORT Malaga tank             253   \n",
       "105539  0956217002      0956217         Cartwheel dress             265   \n",
       "105540  0957375001      0957375        CLAIRE HAIR CLAW              72   \n",
       "105541  0959461001      0959461            Lounge dress             265   \n",
       "\n",
       "       product_type_name  product_group_name graphical_appearance_no  \\\n",
       "0               Vest top  Garment Upper body                 1010016   \n",
       "1               Vest top  Garment Upper body                 1010016   \n",
       "2               Vest top  Garment Upper body                 1010017   \n",
       "3                    Bra           Underwear                 1010016   \n",
       "4                    Bra           Underwear                 1010016   \n",
       "...                  ...                 ...                     ...   \n",
       "105537             Socks      Socks & Tights                 1010014   \n",
       "105538          Vest top  Garment Upper body                 1010016   \n",
       "105539             Dress   Garment Full body                 1010016   \n",
       "105540         Hair clip         Accessories                 1010016   \n",
       "105541             Dress   Garment Full body                 1010016   \n",
       "\n",
       "       graphical_appearance_name colour_group_code colour_group_name  ...  \\\n",
       "0                          Solid                09             Black  ...   \n",
       "1                          Solid                10             White  ...   \n",
       "2                         Stripe                11         Off White  ...   \n",
       "3                          Solid                09             Black  ...   \n",
       "4                          Solid                10             White  ...   \n",
       "...                          ...               ...               ...  ...   \n",
       "105537           Placement print                09             Black  ...   \n",
       "105538                     Solid                09             Black  ...   \n",
       "105539                     Solid                09             Black  ...   \n",
       "105540                     Solid                09             Black  ...   \n",
       "105541                     Solid                11         Off White  ...   \n",
       "\n",
       "          department_name index_code        index_name index_group_no  \\\n",
       "0            Jersey Basic          A        Ladieswear              1   \n",
       "1            Jersey Basic          A        Ladieswear              1   \n",
       "2            Jersey Basic          A        Ladieswear              1   \n",
       "3          Clean Lingerie          B  Lingeries/Tights              1   \n",
       "4          Clean Lingerie          B  Lingeries/Tights              1   \n",
       "...                   ...        ...               ...            ...   \n",
       "105537          Socks Bin          F          Menswear              3   \n",
       "105538             Jersey          A        Ladieswear              1   \n",
       "105539             Jersey          A        Ladieswear              1   \n",
       "105540  Small Accessories          D           Divided              2   \n",
       "105541             Jersey          A        Ladieswear              1   \n",
       "\n",
       "       index_group_name section_no            section_name garment_group_no  \\\n",
       "0            Ladieswear         16  Womens Everyday Basics             1002   \n",
       "1            Ladieswear         16  Womens Everyday Basics             1002   \n",
       "2            Ladieswear         16  Womens Everyday Basics             1002   \n",
       "3            Ladieswear         61         Womens Lingerie             1017   \n",
       "4            Ladieswear         61         Womens Lingerie             1017   \n",
       "...                 ...        ...                     ...              ...   \n",
       "105537         Menswear         26           Men Underwear             1021   \n",
       "105538       Ladieswear          2                    H&M+             1005   \n",
       "105539       Ladieswear         18            Womens Trend             1005   \n",
       "105540          Divided         52     Divided Accessories             1019   \n",
       "105541       Ladieswear         18            Womens Trend             1005   \n",
       "\n",
       "       garment_group_name                                        detail_desc  \n",
       "0            Jersey Basic            Jersey top with narrow shoulder straps.  \n",
       "1            Jersey Basic            Jersey top with narrow shoulder straps.  \n",
       "2            Jersey Basic            Jersey top with narrow shoulder straps.  \n",
       "3       Under-, Nightwear  Microfibre T-shirt bra with underwired, moulde...  \n",
       "4       Under-, Nightwear  Microfibre T-shirt bra with underwired, moulde...  \n",
       "...                   ...                                                ...  \n",
       "105537   Socks and Tights  Socks in a fine-knit cotton blend with a small...  \n",
       "105538       Jersey Fancy  Loose-fitting sports vest top in ribbed fast-d...  \n",
       "105539       Jersey Fancy  Short, A-line dress in jersey with a round nec...  \n",
       "105540        Accessories                           Large plastic hair claw.  \n",
       "105541       Jersey Fancy  Calf-length dress in ribbed jersey made from a...  \n",
       "\n",
       "[105542 rows x 25 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv(\"./Data/articles.csv\", sep=',', dtype=str)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "article_id                      105542\n",
       "product_code                     47224\n",
       "prod_name                        45875\n",
       "product_type_no                    132\n",
       "product_type_name                  131\n",
       "product_group_name                  19\n",
       "graphical_appearance_no             30\n",
       "graphical_appearance_name           30\n",
       "colour_group_code                   50\n",
       "colour_group_name                   50\n",
       "perceived_colour_value_id            8\n",
       "perceived_colour_value_name          8\n",
       "perceived_colour_master_id          20\n",
       "perceived_colour_master_name        20\n",
       "department_no                      299\n",
       "department_name                    250\n",
       "index_code                          10\n",
       "index_name                          10\n",
       "index_group_no                       5\n",
       "index_group_name                     5\n",
       "section_no                          57\n",
       "section_name                        56\n",
       "garment_group_no                    21\n",
       "garment_group_name                  21\n",
       "detail_desc                      43404\n",
       "dtype: int64"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "article_id False\n",
      "product_code False\n",
      "prod_name False\n",
      "product_type_no False\n",
      "product_type_name False\n",
      "product_group_name False\n",
      "graphical_appearance_no False\n",
      "graphical_appearance_name False\n",
      "colour_group_code False\n",
      "colour_group_name False\n",
      "perceived_colour_value_id False\n",
      "perceived_colour_value_name False\n",
      "perceived_colour_master_id False\n",
      "perceived_colour_master_name False\n",
      "department_no False\n",
      "department_name False\n",
      "index_code False\n",
      "index_name False\n",
      "index_group_no False\n",
      "index_group_name False\n",
      "section_no False\n",
      "section_name False\n",
      "garment_group_no False\n",
      "garment_group_name False\n",
      "detail_desc True\n"
     ]
    }
   ],
   "source": [
    "for col in df.columns:\n",
    "    detect_nan = df[col].isnull().values.any()\n",
    "    print(col, detect_nan)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>customer_id</th>\n",
       "      <th>FN</th>\n",
       "      <th>Active</th>\n",
       "      <th>club_member_status</th>\n",
       "      <th>fashion_news_frequency</th>\n",
       "      <th>age</th>\n",
       "      <th>postal_code</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00000dbacae5abe5e23885899a1fa44253a17956c6d1c3...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>ACTIVE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>49</td>\n",
       "      <td>52043ee2162cf5aa7ee79974281641c6f11a68d276429a...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0000423b00ade91418cceaf3b26c6af3dd342b51fd051e...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>ACTIVE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>25</td>\n",
       "      <td>2973abc54daa8a5f8ccfe9362140c63247c5eee03f1d93...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000058a12d5b43e67d225668fa1f8d618c13dc232df0ca...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>ACTIVE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>24</td>\n",
       "      <td>64f17e6a330a85798e4998f62d0930d14db8db1c054af6...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00005ca1c9ed5f5146b52ac8639a40ca9d57aeff4d1bd2...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>ACTIVE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>54</td>\n",
       "      <td>5d36574f52495e81f019b680c843c443bd343d5ca5b1c2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>00006413d8573cd20ed7128e53b7b13819fe5cfc2d801f...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ACTIVE</td>\n",
       "      <td>Regularly</td>\n",
       "      <td>52</td>\n",
       "      <td>25fa5ddee9aac01b35208d01736e57942317d756b32ddd...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1371975</th>\n",
       "      <td>ffffbbf78b6eaac697a8a5dfbfd2bfa8113ee5b403e474...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>ACTIVE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>24</td>\n",
       "      <td>7aa399f7e669990daba2d92c577b52237380662f36480b...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1371976</th>\n",
       "      <td>ffffcd5046a6143d29a04fb8c424ce494a76e5cdf4fab5...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>ACTIVE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>21</td>\n",
       "      <td>3f47f1279beb72215f4de557d950e0bfa73789d24acb5e...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1371977</th>\n",
       "      <td>ffffcf35913a0bee60e8741cb2b4e78b8a98ee5ff2e6a1...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ACTIVE</td>\n",
       "      <td>Regularly</td>\n",
       "      <td>21</td>\n",
       "      <td>4563fc79215672cd6a863f2b4bf56b8f898f2d96ed590e...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1371978</th>\n",
       "      <td>ffffd7744cebcf3aca44ae7049d2a94b87074c3d4ffe38...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ACTIVE</td>\n",
       "      <td>Regularly</td>\n",
       "      <td>18</td>\n",
       "      <td>8892c18e9bc3dca6aa4000cb8094fc4b51ee8db2ed14d7...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1371979</th>\n",
       "      <td>ffffd9ac14e89946416d80e791d064701994755c3ab686...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>PRE-CREATE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>65</td>\n",
       "      <td>0a1a03306fb2f62164c2a439b38c0caa64b40deaae8687...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1371980 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                               customer_id   FN Active  \\\n",
       "0        00000dbacae5abe5e23885899a1fa44253a17956c6d1c3...  NaN    NaN   \n",
       "1        0000423b00ade91418cceaf3b26c6af3dd342b51fd051e...  NaN    NaN   \n",
       "2        000058a12d5b43e67d225668fa1f8d618c13dc232df0ca...  NaN    NaN   \n",
       "3        00005ca1c9ed5f5146b52ac8639a40ca9d57aeff4d1bd2...  NaN    NaN   \n",
       "4        00006413d8573cd20ed7128e53b7b13819fe5cfc2d801f...  1.0    1.0   \n",
       "...                                                    ...  ...    ...   \n",
       "1371975  ffffbbf78b6eaac697a8a5dfbfd2bfa8113ee5b403e474...  NaN    NaN   \n",
       "1371976  ffffcd5046a6143d29a04fb8c424ce494a76e5cdf4fab5...  NaN    NaN   \n",
       "1371977  ffffcf35913a0bee60e8741cb2b4e78b8a98ee5ff2e6a1...  1.0    1.0   \n",
       "1371978  ffffd7744cebcf3aca44ae7049d2a94b87074c3d4ffe38...  1.0    1.0   \n",
       "1371979  ffffd9ac14e89946416d80e791d064701994755c3ab686...  NaN    NaN   \n",
       "\n",
       "        club_member_status fashion_news_frequency age  \\\n",
       "0                   ACTIVE                   NONE  49   \n",
       "1                   ACTIVE                   NONE  25   \n",
       "2                   ACTIVE                   NONE  24   \n",
       "3                   ACTIVE                   NONE  54   \n",
       "4                   ACTIVE              Regularly  52   \n",
       "...                    ...                    ...  ..   \n",
       "1371975             ACTIVE                   NONE  24   \n",
       "1371976             ACTIVE                   NONE  21   \n",
       "1371977             ACTIVE              Regularly  21   \n",
       "1371978             ACTIVE              Regularly  18   \n",
       "1371979         PRE-CREATE                   NONE  65   \n",
       "\n",
       "                                               postal_code  \n",
       "0        52043ee2162cf5aa7ee79974281641c6f11a68d276429a...  \n",
       "1        2973abc54daa8a5f8ccfe9362140c63247c5eee03f1d93...  \n",
       "2        64f17e6a330a85798e4998f62d0930d14db8db1c054af6...  \n",
       "3        5d36574f52495e81f019b680c843c443bd343d5ca5b1c2...  \n",
       "4        25fa5ddee9aac01b35208d01736e57942317d756b32ddd...  \n",
       "...                                                    ...  \n",
       "1371975  7aa399f7e669990daba2d92c577b52237380662f36480b...  \n",
       "1371976  3f47f1279beb72215f4de557d950e0bfa73789d24acb5e...  \n",
       "1371977  4563fc79215672cd6a863f2b4bf56b8f898f2d96ed590e...  \n",
       "1371978  8892c18e9bc3dca6aa4000cb8094fc4b51ee8db2ed14d7...  \n",
       "1371979  0a1a03306fb2f62164c2a439b38c0caa64b40deaae8687...  \n",
       "\n",
       "[1371980 rows x 7 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 = pd.read_csv(\"./Data/customers.csv\", sep=',', dtype=str)\n",
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "customer_id False\n",
      "FN True\n",
      "Active True\n",
      "club_member_status True\n",
      "fashion_news_frequency True\n",
      "age True\n",
      "postal_code False\n"
     ]
    }
   ],
   "source": [
    "for col in df1.columns:\n",
    "    detect_nan = df1[col].isnull().values.any()\n",
    "    print(col, detect_nan)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "36.386964565794"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1['age'].astype('float').mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>t_dat</th>\n",
       "      <th>customer_id</th>\n",
       "      <th>article_id</th>\n",
       "      <th>price</th>\n",
       "      <th>sales_channel_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-09-20</td>\n",
       "      <td>000058a12d5b43e67d225668fa1f8d618c13dc232df0ca...</td>\n",
       "      <td>0663713001</td>\n",
       "      <td>0.050830508474576264</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018-09-20</td>\n",
       "      <td>000058a12d5b43e67d225668fa1f8d618c13dc232df0ca...</td>\n",
       "      <td>0541518023</td>\n",
       "      <td>0.03049152542372881</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018-09-20</td>\n",
       "      <td>00007d2de826758b65a93dd24ce629ed66842531df6699...</td>\n",
       "      <td>0505221004</td>\n",
       "      <td>0.01523728813559322</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2018-09-20</td>\n",
       "      <td>00007d2de826758b65a93dd24ce629ed66842531df6699...</td>\n",
       "      <td>0685687003</td>\n",
       "      <td>0.016932203389830508</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2018-09-20</td>\n",
       "      <td>00007d2de826758b65a93dd24ce629ed66842531df6699...</td>\n",
       "      <td>0685687004</td>\n",
       "      <td>0.016932203389830508</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31788319</th>\n",
       "      <td>2020-09-22</td>\n",
       "      <td>fff2282977442e327b45d8c89afde25617d00124d0f999...</td>\n",
       "      <td>0929511001</td>\n",
       "      <td>0.05930508474576271</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31788320</th>\n",
       "      <td>2020-09-22</td>\n",
       "      <td>fff2282977442e327b45d8c89afde25617d00124d0f999...</td>\n",
       "      <td>0891322004</td>\n",
       "      <td>0.042355932203389825</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31788321</th>\n",
       "      <td>2020-09-22</td>\n",
       "      <td>fff380805474b287b05cb2a7507b9a013482f7dd0bce0e...</td>\n",
       "      <td>0918325001</td>\n",
       "      <td>0.04320338983050847</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31788322</th>\n",
       "      <td>2020-09-22</td>\n",
       "      <td>fff4d3a8b1f3b60af93e78c30a7cb4cf75edaf2590d3e5...</td>\n",
       "      <td>0833459002</td>\n",
       "      <td>0.00676271186440678</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31788323</th>\n",
       "      <td>2020-09-22</td>\n",
       "      <td>fffef3b6b73545df065b521e19f64bf6fe93bfd450ab20...</td>\n",
       "      <td>0898573003</td>\n",
       "      <td>0.033881355932203386</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>31788324 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               t_dat                                        customer_id  \\\n",
       "0         2018-09-20  000058a12d5b43e67d225668fa1f8d618c13dc232df0ca...   \n",
       "1         2018-09-20  000058a12d5b43e67d225668fa1f8d618c13dc232df0ca...   \n",
       "2         2018-09-20  00007d2de826758b65a93dd24ce629ed66842531df6699...   \n",
       "3         2018-09-20  00007d2de826758b65a93dd24ce629ed66842531df6699...   \n",
       "4         2018-09-20  00007d2de826758b65a93dd24ce629ed66842531df6699...   \n",
       "...              ...                                                ...   \n",
       "31788319  2020-09-22  fff2282977442e327b45d8c89afde25617d00124d0f999...   \n",
       "31788320  2020-09-22  fff2282977442e327b45d8c89afde25617d00124d0f999...   \n",
       "31788321  2020-09-22  fff380805474b287b05cb2a7507b9a013482f7dd0bce0e...   \n",
       "31788322  2020-09-22  fff4d3a8b1f3b60af93e78c30a7cb4cf75edaf2590d3e5...   \n",
       "31788323  2020-09-22  fffef3b6b73545df065b521e19f64bf6fe93bfd450ab20...   \n",
       "\n",
       "          article_id                 price sales_channel_id  \n",
       "0         0663713001  0.050830508474576264                2  \n",
       "1         0541518023   0.03049152542372881                2  \n",
       "2         0505221004   0.01523728813559322                2  \n",
       "3         0685687003  0.016932203389830508                2  \n",
       "4         0685687004  0.016932203389830508                2  \n",
       "...              ...                   ...              ...  \n",
       "31788319  0929511001   0.05930508474576271                2  \n",
       "31788320  0891322004  0.042355932203389825                2  \n",
       "31788321  0918325001   0.04320338983050847                1  \n",
       "31788322  0833459002   0.00676271186440678                1  \n",
       "31788323  0898573003  0.033881355932203386                2  \n",
       "\n",
       "[31788324 rows x 5 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = pd.read_csv(\"./Data/transactions_train.csv\", sep=',', dtype=str)\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "import math\n",
    "import numpy as np\n",
    "import torch\n",
    "from torch import nn\n",
    "from torch.nn import Module, Parameter\n",
    "import torch.nn.functional as F"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([1., 2., 3., 4., 5.])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = torch.arange(1., 6.)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "ind = torch.topk(x, 3)[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(tensor([5., 4., 3.]), tensor([4, 3, 2]))"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[ind], ind"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "53d45522881b3fb4d954b08663b412581e4c300eaa71bb6b113858904f668e86"
  },
  "kernelspec": {
   "display_name": "Python 3.7.11 ('cs231n')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.11"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
